//package com.zhentao.controller;
//
//import io.minio.MinioClient;
//import io.minio.ObjectWriteResponse;
//import io.minio.PutObjectArgs;
//import io.minio.errors.*;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.security.InvalidKeyException;
//import java.security.NoSuchAlgorithmException;
//
//@RestController
//@RequestMapping("/minio")
//public class MinioController {
//    @RequestMapping("/upload")
//    public String upload(String img) throws ServerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
//        //1.创建minio的客户端
//        MinioClient minioClient = MinioClient.builder().credentials("minioadmin", "minioadmin")
//                .endpoint("http://39.96.169.152:9000").build();
//
//        FileInputStream fileInputStream = new FileInputStream("D:/img/image/"+img);
//
//        //2.执行上传操作  0上传的参数
//        PutObjectArgs putObjectArgs = PutObjectArgs.builder().bucket("test")  //桶
//                .object(img)
//                .contentType("image/jpg")  //文件类型
//                //-1 minio在进行文件上传的时候，如果文件太大，会进行分片操作，默认大小是5M
//                .stream(fileInputStream, fileInputStream.available(), -1)
//                .build();
//
//        //3. 执行上传才走  1 上传
//        ObjectWriteResponse response = minioClient.putObject(putObjectArgs);
//        System.out.println(response);
//        //4.获取地址
//        String path =minioClient.getObjectUrl(putObjectArgs.bucket(),putObjectArgs.object());
//        System.out.println(path);
//        return "";
//    }
//}
